home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solutions.solon.com (Peter Seebach)
- Newsgroups: comp.lang.c
- Subject: Re: variable-lenght argument list
- Date: 18 Mar 1996 18:36:16 -0600
- Organization: Usenet Fact Police (Undercover)
- Message-ID: <4ikvi0$89n@solutions.solon.com>
- References: <4icl0o$b3j@saturn.exodus.net> <GDR11.96Mar18184655@cl.cam.ac.uk>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <GDR11.96Mar18184655@cl.cam.ac.uk>,
- Gareth Rees <gdr11@cl.cam.ac.uk> wrote:
- >I note that the GNU coding standards suggest the following dreadful
- >hack, which would render your program unportable to many systems (and
- >maybe even to your own system should you change compiler). But these
- >may not be important considerations.
-
- > In certain cases, it is ok to pass integer and pointer arguments
- > indiscriminately to the same function, and use no prototype on any
- > system. For example, many GNU programs have error-reporting functions
- > that pass their arguments along to `printf' and friends:
-
- > error (s, a1, a2, a3)
- > char *s;
- > int a1, a2, a3;
- > {
- > fprintf (stderr, "error: ");
- > fprintf (stderr, s, a1, a2, a3);
- > }
-
- > In practice, this works on all machines, and it is much simpler than
- > any "correct" alternative. Be sure *not* to use a prototype for such
- > functions.
-
- A few notes:
-
- 1. This fails for arguments over 3 times sizeof(int), for the obvious reason.
- 2. This fails with floating point values on some machines.
- 3. This uses the obsolescent feature of old-style declarations.
-
- In practice, on any machine this works on, there is a trivial way to
- do things "correctly" based on <varargs.h> or <stdarg.h>. Currently,
- every machine to which gcc is ported has one or the other (assuming
- bc-init.c compiles), and <stdarg.h> is available for all ANSI systems.
-
- This is probably the single most glaring idiocy in the GNU coding
- standards.
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- FUCK the communications decency act. Goddamned government. [literally.]
- The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
-